package com.learn.code.utils.concurrent;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author : 翌擎科技
 * @date : 2022/7/28 15:35
 */
public class CountDownLatchV {


    private ReentrantLock lock = new ReentrantLock();
    private Condition condition = lock.newCondition();
    private int curValue;

    public CountDownLatchV(int curValue) {
        this.curValue = curValue;

        HashMap<String,String> map=new HashMap<>();
        List<String> list=new ArrayList<>();
        StringBuffer stringBuffer=new StringBuffer();
        stringBuffer.append("23");
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append("1231");
    }

    public void countDown(){
        try {
            lock.lock();
            curValue--;
            if (curValue<=0){
                condition.signalAll();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }


}
